﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<DVSProject.Models.AccessModels>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    ResultRemar
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">
        $(function () {
            var pointResultRemarkI = parseInt($('#ResultRemarkPointI').val());
            var pointResultRemarkII = parseInt($('#ResultRemarkPointII').val());
            var pointResultRemarkIII = parseInt($('#ResultRemarkPointIII').val());
            var pointResultRemarkIV = parseInt($('#ResultRemarkPointIV').val());
            var pointResultRemarkV = parseInt($('#ResultRemarkPointV').val());

            TotalPoint();
            GetResultRemarkI(false, pointResultRemarkI);
            GetResultRemarkII(false, pointResultRemarkII);
            GetResultRemarkIII(false, pointResultRemarkIII);
            GetResultRemarkIV(false, pointResultRemarkIV);
            GetResultRemarkV(false, pointResultRemarkV);

            $('select[name="ResultRemarksI"]').click(function (event) {
                alert('ccc');
            });

            


            $('#SoilRemovalBit_I').change(function () {
                alert($('#ResultRemarksI').val());
                var isChecked = $('#SoilRemovalBit_I:checked').val() ? true : false;
                if (isChecked) {
                    pointResultRemarkI -= 1;
                } else {
                    pointResultRemarkI += 1;
                }
                $('#ResultRemarkPointI').val(pointResultRemarkI);
                TotalPoint();
                if (pointResultRemarkI == 3) {
                    GetResultRemarkI(false, pointResultRemarkI);
                } else {
                    GetResultRemarkI(true, pointResultRemarkI);
                }

            });

            $('#FilmStreakBit_I').change(function () {
                var isChecked = $('#FilmStreakBit_I:checked').val() ? true : false;
                if (isChecked) {
                    pointResultRemarkI -= 1;
                } else {
                    pointResultRemarkI += 1;
                }
                $('#ResultRemarkPointI').val(pointResultRemarkI);
                TotalPoint();
                if (pointResultRemarkI == 3) {
                    GetResultRemarkI(false, pointResultRemarkI);
                } else {
                    GetResultRemarkI(true, pointResultRemarkI);
                }
            });

            $('#SpottedBit_I').change(function () {
                var isChecked = $('#SpottedBit_I:checked').val() ? true : false;
                if (isChecked) {
                    pointResultRemarkI = parseInt(pointResultRemarkI) - 1;
                } else {
                    pointResultRemarkI = parseInt(pointResultRemarkI) + 1;
                }
                $('#ResultRemarkPointI').val(pointResultRemarkI);
                TotalPoint();
                if (pointResultRemarkI == 3) {
                    GetResultRemarkI(false, pointResultRemarkI);
                } else {
                    GetResultRemarkI(true, pointResultRemarkI);
                }
            });

            //------------------------

            $('#SoilRemovalBit_II').change(function () {
                var isChecked = $('#SoilRemovalBit_II:checked').val() ? true : false;
                if (isChecked) {
                    pointResultRemarkII -= 1;
                } else {
                    pointResultRemarkII += 1;
                }
                $('#ResultRemarkPointII').val(pointResultRemarkII);
                TotalPoint();

                if (pointResultRemarkII == 3) {
                    GetResultRemarkII(false, pointResultRemarkII);
                } else {
                    GetResultRemarkII(true, pointResultRemarkII);
                }
            });

            $('#FilmStreakBit_II').change(function () {
                var isChecked = $('#FilmStreakBit_II:checked').val() ? true : false;
                if (isChecked) {
                    pointResultRemarkII -= 1;
                } else {
                    pointResultRemarkII += 1;
                }
                $('#ResultRemarkPointII').val(pointResultRemarkII);
                TotalPoint();

                if (pointResultRemarkII == 3) {
                    GetResultRemarkII(false, pointResultRemarkII);
                } else {
                    GetResultRemarkII(true, pointResultRemarkII);
                }
            });

            $('#SpottedBit_II').change(function () {
                var isChecked = $('#SpottedBit_II:checked').val() ? true : false;
                if (isChecked) {
                    pointResultRemarkII -= 1;
                } else {
                    pointResultRemarkII += 1;
                }
                $('#ResultRemarkPointII').val(pointResultRemarkII);
                TotalPoint();

                if (pointResultRemarkII == 3) {
                    GetResultRemarkII(false, pointResultRemarkII);
                } else {
                    GetResultRemarkII(true, pointResultRemarkII);
                }
            });

            //---------------------------------------
            $('#SoilRemovalBit_III').change(function () {
                var isChecked = $('#SoilRemovalBit_III:checked').val() ? true : false;
                if (isChecked) {
                    pointResultRemarkIII -= 1;
                } else {
                    pointResultRemarkIII += 1;
                }
                $('#ResultRemarkPointIII').val(pointResultRemarkIII);
                TotalPoint();

                if (pointResultRemarkIII == 3) {
                    GetResultRemarkIII(false, pointResultRemarkIII);
                } else {
                    GetResultRemarkIII(true, pointResultRemarkIII);
                }
            });

            $('#FilmStreakBit_III').change(function () {
                var isChecked = $('#FilmStreakBit_III:checked').val() ? true : false;
                if (isChecked) {
                    pointResultRemarkIII -= 1;
                } else {
                    pointResultRemarkIII += 1;
                }
                $('#ResultRemarkPointIII').val(pointResultRemarkIII);
                TotalPoint();

                if (pointResultRemarkIII == 3) {
                    GetResultRemarkIII(false, pointResultRemarkIII);
                } else {
                    GetResultRemarkIII(true, pointResultRemarkIII);
                }
            });

            $('#SpottedBit_III').change(function () {
                var isChecked = $('#SpottedBit_III:checked').val() ? true : false;
                if (isChecked) {
                    pointResultRemarkIII -= 1;
                } else {
                    pointResultRemarkIII += 1;
                }
                $('#ResultRemarkPointIII').val(pointResultRemarkIII);
                TotalPoint();

                if (pointResultRemarkIII == 3) {
                    GetResultRemarkIII(false, pointResultRemarkIII);
                } else {
                    GetResultRemarkIII(true, pointResultRemarkIII);
                }
            });

            //---------------------------------------
            $('#SoilRemovalBit_IV').change(function () {
                var isChecked = $('#SoilRemovalBit_IV:checked').val() ? true : false;
                if (isChecked) {
                    pointResultRemarkIV -= 1;
                } else {
                    pointResultRemarkIV += 1;
                }
                $('#ResultRemarkPointIV').val(pointResultRemarkIV);
                TotalPoint();

                if (pointResultRemarkIV == 3) {
                    GetResultRemarkIV(false, pointResultRemarkIV);
                } else {
                    GetResultRemarkIV(true, pointResultRemarkIV);
                }
            });

            $('#FilmStreakBit_IV').change(function () {
                var isChecked = $('#FilmStreakBit_IV:checked').val() ? true : false;
                if (isChecked) {
                    pointResultRemarkIV -= 1;
                } else {
                    pointResultRemarkIV += 1;
                }
                $('#ResultRemarkPointIV').val(pointResultRemarkIV);
                TotalPoint();

                if (pointResultRemarkIV == 3) {
                    GetResultRemarkIV(false, pointResultRemarkIV);
                } else {
                    GetResultRemarkIV(true, pointResultRemarkIV);
                }
            });

            $('#SpottedBit_IV').change(function () {
                var isChecked = $('#SpottedBit_IV:checked').val() ? true : false;
                if (isChecked) {
                    pointResultRemarkIV -= 1;
                } else {
                    pointResultRemarkIV += 1;
                }
                $('#ResultRemarkPointIV').val(pointResultRemarkIV);
                TotalPoint();

                if (pointResultRemarkIV == 3) {
                    GetResultRemarkIV(false, pointResultRemarkIV);
                } else {
                    GetResultRemarkIV(true, pointResultRemarkIV);
                }
            });

            //---------------------------------------
            $('#SoilRemovalBit_V').change(function () {
                var isChecked = $('#SoilRemovalBit_V:checked').val() ? true : false;
                if (isChecked) {
                    pointResultRemarkV -= 1;
                } else {
                    pointResultRemarkV += 1;
                }
                $('#ResultRemarkPointV').val(pointResultRemarkV);
                TotalPoint();

                if (pointResultRemarkV == 3) {
                    GetResultRemarkV(false, pointResultRemarkV);
                } else {
                    GetResultRemarkV(true, pointResultRemarkV);
                }
            });

            $('#FilmStreakBit_V').change(function () {
                var isChecked = $('#FilmStreakBit_V:checked').val() ? true : false;
                if (isChecked) {
                    pointResultRemarkV -= 1;
                } else {
                    pointResultRemarkV += 1;
                }
                $('#ResultRemarkPointV').val(pointResultRemarkV);
                TotalPoint();

                if (pointResultRemarkV == 3) {
                    GetResultRemarkV(false, pointResultRemarkV);
                } else {
                    GetResultRemarkV(true, pointResultRemarkV);
                }
            });

            $('#SpottedBit_V').change(function () {
                var isChecked = $('#SpottedBit_V:checked').val() ? true : false;
                if (isChecked) {
                    pointResultRemarkV -= 1;
                } else {
                    pointResultRemarkV += 1;
                }
                $('#ResultRemarkPointV').val(pointResultRemarkV);
                TotalPoint();

                if (pointResultRemarkV == 3) {
                    GetResultRemarkV(false, pointResultRemarkV);
                } else {
                    GetResultRemarkV(true, pointResultRemarkV);
                }
            });

            function TotalPoint() {
                $("#TotalPoint").val(parseInt(pointResultRemarkI) + parseInt(pointResultRemarkII) + parseInt(pointResultRemarkIII) + parseInt(pointResultRemarkIV) + parseInt(pointResultRemarkV));

            }


            function GetResultRemarkI(isFilter, point) {


                // var serviceURL = '/Access/ResultRemarkIProcess';
                var actionUrl = '<%=Url.Action("ResultRemarkIProcess","Access") %>';
                //                  $.ajax({
                //                    type: "POST",
                //                    url: serviceURL,
                //                    contentType: "application/json; charset=utf-8",
                //                    data: { a: "testing" },
                //                    dataType: "json",
                //                    success: function() { alert('Success'); },
                //                    error: function() { alert('Error'); }
                //                    });


                //                    $.get(actionUrl, function (data) {
                //                        $("#ResultRemarkI").html(data);
                //                    });

                $.ajax({
                    type: "GET",
                    url: actionUrl,
                    contentType: "application/json; charset=utf-8",
                    data: ({ isFitter: isFilter }),
                    success: function (data) {
                        $("#ResultRemarkI").html(data);

                        if (point < 3) {
                            $('#ResultRemarksI').removeAttr("disabled");
                        }
                    },
                    error: function () {
                        //SimilarSlider.html("<div style='color:#682929;text-align:center;font-weight:bold;'>¢Íâ·É¤èÐ ÃÐººäÁèÊÒÁÒÃ¶áÊ´§Ë¹éÒ¹Õéä´éã¹¢³Ð¹Õé</div>");
                    }
                });
            }

            function GetResultRemarkII(isFilter, point) {
                var actionUrl = '<%=Url.Action("ResultRemarkIIProcess","Access") %>'
                $.ajax({
                    type: "GET",
                    url: actionUrl,
                    contentType: "application/json; charset=utf-8",
                    data: ({ isFitter: isFilter }),
                    success: function (data) {

                        $("#ResultRemarkII").html(data);

                        if (point < 3) {
                            $('#ResultRemarksII').removeAttr("disabled");
                        }
                    },
                    error: function (data) {
                        alert(data);
                        //SimilarSlider.html("<div style='color:#682929;text-align:center;font-weight:bold;'>¢Íâ·É¤èÐ ÃÐººäÁèÊÒÁÒÃ¶áÊ´§Ë¹éÒ¹Õéä´éã¹¢³Ð¹Õé</div>");
                    }
                });
            }

            function GetResultRemarkIII(isFilter, point) {
                var actionUrl = '<%=Url.Action("ResultRemarkIIIProcess","Access") %>'
                $.ajax({
                    type: "GET",
                    url: actionUrl,
                    contentType: "application/json; charset=utf-8",
                    data: ({ isFitter: isFilter }),
                    success: function (data) {

                        $("#ResultRemarkIII").html(data);

                        if (point < 3) {
                            $('#ResultRemarksIII').removeAttr("disabled");
                        }
                    },
                    error: function (data) {
                        alert(data);
                        //SimilarSlider.html("<div style='color:#682929;text-align:center;font-weight:bold;'>¢Íâ·É¤èÐ ÃÐººäÁèÊÒÁÒÃ¶áÊ´§Ë¹éÒ¹Õéä´éã¹¢³Ð¹Õé</div>");
                    }
                });
            }

            function GetResultRemarkIV(isFilter, point) {
                var actionUrl = '<%=Url.Action("ResultRemarkIVProcess","Access") %>'
                $.ajax({
                    type: "GET",
                    url: actionUrl,
                    contentType: "application/json; charset=utf-8",
                    data: ({ isFitter: isFilter }),
                    success: function (data) {

                        $("#ResultRemarkIV").html(data);

                        if (point < 3) {
                            $('#ResultRemarksIV').removeAttr("disabled");
                        }
                    },
                    error: function (data) {
                        alert(data);
                        //SimilarSlider.html("<div style='color:#682929;text-align:center;font-weight:bold;'>¢Íâ·É¤èÐ ÃÐººäÁèÊÒÁÒÃ¶áÊ´§Ë¹éÒ¹Õéä´éã¹¢³Ð¹Õé</div>");
                    }
                });
            }

            function GetResultRemarkV(isFilter, point) {
                var actionUrl = '<%=Url.Action("ResultRemarkVProcess","Access") %>'
                $.ajax({
                    type: "GET",
                    url: actionUrl,
                    contentType: "application/json; charset=utf-8",
                    data: ({ isFitter: isFilter }),
                    success: function (data) {

                        $("#ResultRemarkV").html(data);

                        if (point < 3) {
                            $('#ResultRemarksV').removeAttr("disabled");
                        }
                    },
                    error: function (data) {
                        alert(data);
                        //SimilarSlider.html("<div style='color:#682929;text-align:center;font-weight:bold;'>¢Íâ·É¤èÐ ÃÐººäÁèÊÒÁÒÃ¶áÊ´§Ë¹éÒ¹Õéä´éã¹¢³Ð¹Õé</div>");
                    }
                });
            }

        });
         
    </script>
    <h2>
        RESULTS ผลการล้าง</h2>
    <% using (Html.BeginForm())
       {%>
    <%= Html.ValidationSummary(true) %>
    <div class="CSSTableGenerator">
        <table>
            <tr>
                <th>
                    <label>
                        Result ผลการล้าง</label>
                </th>
                <th>
                    <label>
                        Soiled/ไม่สะอาด</label>
                </th>
                <th>
                    <label>
                        Film/Streak มีคราบ</label>
                </th>
                <th>
                    <label>
                        Not Dry/ไม่แห้ง</label>
                </th>
                <th style="width: 20px">
                    <label>
                        Remarks หมายเหตุ</label>
                </th>
                <th style="width: 200px">
                    <label>
                        Point คะแนน</label>
                </th>
            </tr>
            <tr>
                <td>
                    <label>
                        Glasses แก้ว</label>
                </td>
                <td align="center">
                    <%= Html.CheckBoxFor(model => model.SoilRemovalBit_I)%>
                </td>
               
                <td align="center">
                    <%= Html.CheckBoxFor(model => model.FilmStreakBit_I)%>
                </td>
                <td align="center">
                    <%= Html.CheckBoxFor(model => model.SpottedBit_I)%>
                </td>
                <td style="width: 200px">
                    <%-- <%=@Html.DropDownListFor(model => model.ResultRemarksI, Model.ResultRemarkISelect, new { @disabled = "disabled" })%>--%>
                    <div id="ResultRemarkI">
                    </div>
                </td>
                <td align="center">
                    <%=@Html.TextBoxFor(model => model.ResultRemarkPointI, new { @Value = "3", @readonly = "true" })%>
                </td>
            </tr>
            <tr>
                <td>
                    <label>
                        Cup ถ้วย</label>
                </td>
                <td align="center">
                    <%= Html.CheckBoxFor(model => model.SoilRemovalBit_II)%>
                </td>
                <td align="center">
                    <%= Html.CheckBoxFor(model => model.FilmStreakBit_II)%>
                </td>
                <td align="center">
                    <%= Html.CheckBoxFor(model => model.SpottedBit_II)%>
                </td>
                <td style="width: 200px">
                    <%-- <%=@Html.DropDownListFor(model => model.ResultRemarksII, Model.ResultRemarkIISelect, new { @disabled = "disabled" })%>--%>
                    <div id="ResultRemarkII">
                    </div>
                </td>
                <td align="center">
                    <%=@Html.TextBoxFor(model => model.ResultRemarkPointII, new { @Value = "3", @readonly = "true" })%>
                </td>
            </tr>
            <tr>
                <td>
                    <label>
                        Plates จาน</label>
                </td>
                <td align="center">
                    <%= Html.CheckBoxFor(model => model.SoilRemovalBit_III)%>
                </td>
                <td align="center">
                    <%= Html.CheckBoxFor(model => model.FilmStreakBit_III)%>
                </td>
                <td align="center">
                    <%= Html.CheckBoxFor(model => model.SpottedBit_III)%>
                </td>
                <td style="width: 200px">
                    <%-- <%=@Html.DropDownListFor(model => model.ResultRemarksIII, Model.ResultRemarkIIISelect, new { @disabled = "disabled" })%>--%>
                    <div id="ResultRemarkIII">
                    </div>
                </td>
                <td align="center">
                    <%=@Html.TextBoxFor(model => model.ResultRemarkPointIII, new { @Value = "3", @readonly = "true" })%>
                </td>
            </tr>
            <tr>
                <td>
                    <label>
                        Flatware มีด/ช้อน/ส้อม</label>
                </td>
                <td align="center">
                    <%= Html.CheckBoxFor(model => model.SoilRemovalBit_IV)%>
                </td>
                <td align="center">
                    <%= Html.CheckBoxFor(model => model.FilmStreakBit_IV)%>
                </td>
                <td align="center">
                    <%= Html.CheckBoxFor(model => model.SpottedBit_IV)%>
                </td>
                <td style="width: 200px">
                    <%--  <%=@Html.DropDownListFor(model => model.ResultRemarksIV, Model.ResultRemarkIVSelect, new { @disabled = "disabled" })%>
                    --%>
                    <div id="ResultRemarkIV">
                    </div>
                </td>
                <td align="center">
                    <%=@Html.TextBoxFor(model => model.ResultRemarkPointIV, new { @Value = "3", @readonly = "true" })%>
                </td>
            </tr>
            <tr>
                <td>
                    <label>
                        Tray ถาด</label>
                </td>
                <td align="center">
                    <%= Html.CheckBoxFor(model => model.SoilRemovalBit_V)%>
                </td>
                <td align="center">
                    <%= Html.CheckBoxFor(model => model.FilmStreakBit_V)%>
                </td>
                <td align="center">
                    <%= Html.CheckBoxFor(model => model.SpottedBit_V)%>
                </td>
                <td style="width: 200px">
                   <%-- <%=@Html.DropDownListFor(model => model.ResultRemarksV, Model.ResultRemarkVSelect, new { @disabled = "disabled" })%>--%>
                     <div id="ResultRemarkV">
                    </div>
                </td>
                <td align="center">
                    <%=@Html.TextBoxFor(model => model.ResultRemarkPointV, new { @Value = "3", @readonly = "true" })%>
                </td>
            </tr>
            <tr>
                <td>
                    <label>
                        Others/ อื่นๆ</label>
                </td>
                <td align="center">
                </td>
                <td align="center">
                </td>
                <td align="center">
                </td>
                <td>
                </td>
                <td align="center">
                </td>
            </tr>
            <tr>
                <td colspan="5">
                    Total Points คะแนนรวม
                </td>
                <td>
                    <input type="text" id="TotalPoint" readonly="readonly" value="0" />
                </td>
            </tr>
        </table>
    </div>
    <p>
        <input type="submit" class="buttonSummit" value="Next" />
    </p>
    <% } %>
    <div>
        <%= Html.ActionLink("Back to List", "Index") %>
    </div>
</asp:Content>
